import React from 'react';
import { inject, observer } from 'mobx-react';
import { Spin, Checkbox } from 'antd'
import { WeaRightMenu, WeaLocaleProvider,WeaDialog } from 'ecCom';
import { WeaTableNew } from "comsMobx";
import '../../style/export/export.less'
const WeaTable = WeaTableNew.WeaTable;
const getLabel = WeaLocaleProvider.getLabel;


/**
 * 考核设置-考核指标项
 * jiansong 2019/6/18
 */
@inject("exportBlogListStore")
@observer
export default class ExportLogList extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            title: '', 
        }
        this.store = this.props.exportBlogListStore;
    }

    componentDidMount() {
        const { exportBlogListStore } = this.props;
        exportBlogListStore.doInit();
      }

      getShareLevel (detailRow) {
          let shareLevel = "";
        if(detailRow.shareLevel=='1'){
            shareLevel = getLabel(18511, '同部门')
        }else if(detailRow.shareLevel=='2'){
            shareLevel = getLabel(18512, '同分部')
        }else if(detailRow.shareLevel=='3'){
            shareLevel = getLabel(140, '总部')
        }else if(detailRow.shareLevel=='4'){
            shareLevel = getLabel(500141, '同部门级下级部门')
        }else if(detailRow.shareLevel=='5'){
            shareLevel = getLabel(25512, '多分部')
        }else if(detailRow.shareLevel=='6'){
            shareLevel = getLabel(83497, '多部门')
        }
        return shareLevel;
      }


    render() {
        let _this=this;
        const { menu } = _this.props;
        const { loading, tableLogStore,setIds,exportLogDetailIsShow,setExportLogDetailIsShow,detailRow } = _this.store;

        return (
            <Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@qovnga`} spinning={loading}>
                <div>
                <WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@c335ls`}
                    className="quanxian-shezhi"
                    comsWeaTableStore={tableLogStore}
                    hasOrder
                    needScroll
                    getColumns={this.getColumns}
                    onOperatesClick={this.onOperatesClick}
                />
                <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@daln1h`}
                    onCancel={() =>
                        setExportLogDetailIsShow(false,detailRow)
                    }
                    title={getLabel(384113, '添加')+'-'+getLabel(501864, '权限设置')+':'+detailRow.exportIdspan}
                    visible={exportLogDetailIsShow}
                    style={{ width: 800, height: 300 }}
                    hasScroll
                    >
                    1、[{getLabel(21956, '对象类型')+'('+getLabel(106, '对象') +')'}]：{detailRow.exportIdspan}
                    <br />
                    2、[{getLabel(683, '安全级别')}]：{detailRow.seclevelMin=='-1'?'':detailRow.seclevelMin+'-'+detailRow.seclevelMax}
                    <br />
                    3、[{getLabel(3005, '共享级别')}]：{this.getShareLevel(detailRow)}

                </WeaDialog>

                </div>
            </Spin>
        )
    }

    getColumns = columns => {
        const { setExportLogDetailIsShow } = this.store;
        return columns.map(col => {
            if (col.dataIndex == "operateType") {
                col.render = (text, data) => text=='1'?getLabel(384113, '添加'):getLabel(91, '删除')
            } else if (col.dataIndex == 'project') {
                col.render = text => text=='1'?getLabel(517341, '内容导出权限'):''
            } else if (col.dataIndex == 'updateDetail') {
                col.render = (text, record) => text=='1'? <a href="javascript:void(0);" style={{color:'blue'}} onClick={() =>setExportLogDetailIsShow(true,record) }>{getLabel(33564, '查看')}</a>:''
            } 
            return col;
        });
    }
}